package com.foreverwin.jzymes.production.cutter;

import com.foreverwin.jzymes.Application;
import com.foreverwin.jzymes.framework.util.FTPUtil;
import com.foreverwin.jzymes.production.cutter.domain.ToolBreakLog;
import com.foreverwin.jzymes.production.cutter.service.IExportExcelService;
import com.foreverwin.jzymes.production.cutter.service.IToolBreakAdiviceService;
import com.foreverwin.jzymes.production.picking.mapper.PickingMapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration( classes = Application.class)
public class test {
    @Autowired
    IToolBreakAdiviceService toolBreakAdiviceService ;
    @Autowired
    FTPUtil ftpUtil;
    @Autowired
    IExportExcelService exportExcelService;
    @Autowired
    PickingMapper pickingMapper;
    @Test
    public  void  check (){
        ToolBreakLog toolBreakLog = new ToolBreakLog() ;

        toolBreakLog.setShift( "A" );
        toolBreakLog.setSite( "1000" );
        toolBreakLog.setResrce( "05138045" );
        toolBreakLog.setCncType("yijia");
        toolBreakLog.setToolName("804B-DJ203-BX");
        toolBreakLog.setToolLoc("T1");
        toolBreakLog.setQty( 10l );
        toolBreakLog.setMaxUsage(100l);
        toolBreakLog.setActualUsage( 101l );
        toolBreakLog.setTechnicion("ESC");
        toolBreakLog.setBreakType("BAD");
        //toolBreakLog.setBreakAnalysis("sssss");

        toolBreakAdiviceService.insertToolBreak( toolBreakLog );
    }
    @Test
    public  void  chck()  {
    }

    @Test
    public  void  chck1()  {
        Map<String,Object> jsonMap = new HashMap<>();
        jsonMap.put("site","1000");
        jsonMap.put("resrce","");
        jsonMap.put("machineType","804");
        jsonMap.put("startDate","");
        jsonMap.put("endDate","");
        List<ToolBreakLog> toolBreakLogs = toolBreakAdiviceService.selectToolBreak( jsonMap );

        String [] strings = new String[]{"刀具信息"} ;
        exportExcelService.reportExport( toolBreakLogs , "刀具信息");
        while (true){

        }
        //exportExcelService.exportExcel( toolBreakLogs , "xxxxxxx" );
        /*List<Map<String,Object>> list = new ArrayList<>();
        for ( int i=0;i<toolBreakLogs.size();i++ ){
            Map<String,Object> map = new HashMap<>();
            map = exportExcelService.setConditionMap( toolBreakLogs.get(i) );
            list.add( map );
        }*/
       // Map<String,Object> map = exportExcelService.setConditionMap( toolBreakLogs.get(0) );
       // System.out.println( list );
    }

    @Test
    public void  test(){
        /*int machineId = 1;//最大支持1-9个集群机器部署
        String c = UUID.randomUUID().toString();
        System.out.println( c );
        int hashCodeV = c.hashCode();
        System.out.println( hashCodeV );
        if(hashCodeV < 0) {//有可能是负数
            hashCodeV = - hashCodeV;
        }
        // 0 代表前面补充0
        // 4 代表长度为4
        // d 代表参数为正数型
        System.out.println( hashCodeV );
        String Id =  machineId + String.format("%015d", hashCodeV);
        System.out.println( Id );
*/
        Date date = new Date();

        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        System.out.println(sdf.toString());

        String  formDate =sdf.format(date);

        System.out.println(formDate);

        String no = formDate.substring(2);

        System.out.println(no);
    }
}
